#include "link/include/client.h"
int main()
{ 
    user_t usr;
    bzero(&usr,sizeof(user_t));
    strcpy(usr.username,"root");
    strcpy(usr.path,"/");
    int ret;
    optdata_t optd;
    int sockfd;
    client_init(&sockfd,&usr);
    char opt;
    do{
        printf("\033[1;31mPlease choose one option here\033[0m\n\033[5;33m(1:login; 2:enroll): \033[0m");
        fflush(stdout);
        scanf("%c",&opt);
        if('1'==opt){send(sockfd,&opt,1,0);login(sockfd,&usr);}//发送登录信号
        else if('2'==opt){send(sockfd,&opt,1,0);enroll(sockfd,&usr);}
    }while(opt!='1'&&opt!='2');
    while(1)
    {
        ret=get_command(&usr,&optd);
        if(0==ret)
        {
            continue;
        }else if(-1==ret)
        {
            printf("Please enter the right command!\n");
            continue;
        }else
        {
            optd.opt=ret;
            ret=do_command(sockfd,optd,&usr);
            if(-1==ret)
            {
                printf("Something wrong happened!\n");
                break;
            }
        }
    }
    return 0;
}
